<!-- Stored in resoures/views/index.blade.php -->

@extends('base')

@section('style')
<link rel="stylesheet" type="text/css" href="http://petstore.swagger.io/swagger-ui.css">
@endsection

@section('content')
<div class="box">
    <div class="box-header with-border">
        <h3 class="box-title">关注关系</h3>
    </div>
    <!-- /.box-header -->
    <div class="box-body">
        <table class="table">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>名称</th>
                    <th>标识</th>
                    <th>修改时间</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>447</td>
                    <td>点赞反作弊配置</td>
                    <td>praise_prevention</td>
                    <td>2018-01-31 17:20:04</td>
                    <td><button type="button" class="btn btn-block btn-primary btn-xs">管理</button></td>
                    <td><button type="button" class="btn btn-block btn-default btn-xs">修改</button></td>
                    <td><button type="button" class="btn btn-block btn-danger btn-xs">删除</button></td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
<div class="box">
    <div class="box-header with-border">
        <h3 class="box-title">关注关系</h3>
    </div>
    <!-- /.box-header -->
    <div class="box-body">
        <div id="editor_holder">
        </div>
    </div>
</div>
<div class="box">
<div id="swagger-ui"></div>
</div>
@endsection

@section('script')
<script src="http://petstore.swagger.io/swagger-ui-bundle.js"> </script>
<script src="http://petstore.swagger.io/swagger-ui-standalone-preset.js"></script>

<script type="text/javascript">

window.onload = function() {
  
  // Build a system
  const ui = SwaggerUIBundle({
    url: "http://petstore.swagger.io/v2/swagger.json",
    dom_id: '#swagger-ui',
    deepLinking: true,
    presets: [
      SwaggerUIBundle.presets.apis,
      SwaggerUIStandalonePreset
    ],
    plugins: [
      SwaggerUIBundle.plugins.DownloadUrl
    ],
    layout: "StandaloneLayout"
  })

  window.ui = ui
}

// Set default options
JSONEditor.defaults.options.theme = 'bootstrap3';

// Initialize the editor
var editor = new JSONEditor(document.getElementById("editor_holder"),{
  schema: {
      type: "object",
      properties: {
          name: { "type": "string" }
      }
  },
  startval: { "name" : "test", "yaokun" : "123"}
});

/*
// Set the value
editor.setValue({
    name: "John Smith"
});
*/

// Get the value
var data = editor.getValue();
console.log(data.name); // "John Smith"

// Validate
var errors = editor.validate();
if(errors.length) {
  // Not valid
}

// Listen for changes
editor.on("change",  function() {
  // Do something...
});
</script>
@endsection